import { fileURLToPath, URL } from 'node:url'

import { defineConfig } from 'vite'
import vue from '@vitejs/plugin-vue'
import AutoImport from 'unplugin-auto-import/vite'
import Components from 'unplugin-vue-components/vite'
import { ElementPlusResolver } from 'unplugin-vue-components/resolvers'
import vercel from 'vite-plugin-vercel';

export default defineConfig({
  plugins: [
    vue(),
    AutoImport({
      resolvers: [ElementPlusResolver()],
      imports: ['vue','vue-router'],   
      dts: "src/types/auto-imports.d.ts",
    }),
    Components({
      resolvers: [ElementPlusResolver({
        importStyle: 'sass',
      })],
      dts: "src/types/components.d.ts",
    }),
    vercel()
  ],
  resolve: {
    alias: {
      '@': fileURLToPath(new URL('./src', import.meta.url))
    }
  },
  server: {
    port: process.env.PORT as unknown as number,
  },
  css: {
    // css预处理器
    preprocessorOptions: {
      scss: {
        additionalData: '@use "@/style/element/index.scss" as *;;',
        api: 'modern-compiler', // or 'modern'
      }
    }
  }
})
